<!--{template /module/admin/view/head}-->
<div id="left_layout">
	<div id="main_content" class="container-fluid">
		<!--{template /module/admin/view/head_nav}-->
		<div class="row-fluid">
			<div class="well widget">
				<div class="widget-header">
					<h3 class="title">{lang user.index.view.header}</h3>
				</div>
				<div class="widget-content">
					<form class="form-search" id="frm_search" name="frmSearch" action="{$ADMIN_SCRIPT}/user" method="post">
					<div class="action-wrapper">
						<div class="pull-left">
							<a href="javascript:void(null);" id="btn_disable_list" class="btn btn-small" {$dispatches[operations][audit]}>{lang admin.operation.disable}</a>
							<a href="javascript:void(null);" id="btn_enable_list" class="btn btn-small" {$dispatches[operations][audit]}>{lang admin.operation.enable}</a>
							<a href="javascript:void(null);" id="btn_modify_list" class="btn btn-small" {$dispatches[operations][edit]}>{lang admin.operation.modify}</a>
							<a href="javascript:void(null);" id="btn_delete_list" class="btn btn-small" {$dispatches[operations][delete]}>{lang admin.operation.delete}</a>
							<a href="javascript:void(null);" id="btn_export" class="btn btn-small" {$dispatches[operations][export]}>{lang admin.operation.export}</a>
							<a href="{$ADMIN_SCRIPT}/user/_add" {$dispatches[operations][add]} class="btn btn-small">{lang user.index.view.operation.add}</a>
							<span class="muted">{lang user.index.view.tips}</span>
						</div>
						<div class="pull-right" {$dispatches[operations][search]}>
							<div class="input-append" >
								<input type="text" name="txtKeyword" value="{$_var[gp_txtKeyword]}" class="input-small search-query" />
								<button type="submit" class="btn">{lang admin.search.submit}</button>
							</div>
							<button type="button" state="0" class="btn" id="btn_extend_search">{lang admin.search.submit.extend}<i class="micon-arrow-down"></i></button>
						</div>
					</div>
					</form>
					
					<div id="div_extend_search" style="display:none;">
						<hr/>
						<form id="frm_extend_search" name="frmExtendSearch" action="{$ADMIN_SCRIPT}/user&page={$_var[page]}&psize={$_var[psize]}" method="post">
						<input type="hidden" name="hdnSearchShow" id="hdnSearchShow" value="1" />
						<table>
						<tr>
							<td width="46">{lang admin.search.keyword}</td>
							<td>
								<label class="checkbox inline">
									<input type="text" name="txtKeyword" value="{$_var[gp_txtKeyword]}" class="input-medium" />
								</label>
								<label class="checkbox inline">
								<select name="sltType">
									<option value="0" {if $_var['gp_sltType'] == 0}selected="selected"{/if}>{lang user.index.view.search.type.select.0}</option>
						            <option value="1" {if $_var['gp_sltType'] == 1}selected="selected"{/if}>{lang user.index.view.search.type.select.1}</option>
						            <option value="2" {if $_var['gp_sltType'] == 2}selected="selected"{/if}>{lang user.index.view.search.type.select.2}</option>
						            <option value="3" {if $_var['gp_sltType'] == 3}selected="selected"{/if}>{lang user.index.view.search.type.select.3}</option>
						            <option value="4" {if $_var['gp_sltType'] == 4}selected="selected"{/if}>{lang user.index.view.search.type.select.4}</option>
						            <option value="5" {if $_var['gp_sltType'] == 5}selected="selected"{/if}>{lang user.index.view.search.type.select.5}</option>
						            <option value="6" {if $_var['gp_sltType'] == 6}selected="selected"{/if}>{lang user.index.view.search.type.select.6}</option>
						            <option value="6" {if $_var['gp_sltType'] == 7}selected="selected"{/if}>{lang user.index.view.search.type.select.7}</option>
					            </select>
					            </label>
					            
					            <!--{if count($groups) > 0}-->
					            <label class="checkbox inline">
					            <select name="sltGroupID">
				            		<option value="0">{lang user.index.view.search.group.select.0}</option>
				            		<!--{loop $groups $group}-->
				            		<option value="{$group[GROUPID]}" {if $_var['gp_sltGroupID'] == $group['GROUPID']}selected="selected"{/if}>{$group[CNAME]}</option>
				            		<!--{/loop}-->
				            	</select>
				            	</label>
				            	<!--{/if}-->
				            	
					            <label class="checkbox inline">
				            	<select name="sltIsAudit">
				            		<option value="0" {if $_var['gp_sltIsAudit'] == 0}selected="selected"{/if}>{lang user.index.view.search.isaudit.select.0}</option>
						            <option value="1" {if $_var['gp_sltIsAudit'] == 1}selected="selected"{/if}>{lang user.index.view.search.isaudit.select.1}</option>
						            <option value="2" {if $_var['gp_sltIsAudit'] == 2}selected="selected"{/if}>{lang user.index.view.search.isaudit.select.2}</option>
				            	</select>
				            	</label>
					            <label class="checkbox inline">
				            	<select name="sltSort">
						            <option value="0">{lang user.index.view.search.sort.select.0}</option>
						            <option value="1" {if $_var['gp_sltSort'] == 1}selected="selected"{/if}>{lang user.index.view.search.sort.select.1}</option>
						            <option value="2" {if $_var['gp_sltSort'] == 2}selected="selected"{/if}>{lang user.index.view.search.sort.select.2}</option>
						            <option value="3" {if $_var['gp_sltSort'] == 3}selected="selected"{/if}>{lang user.index.view.search.sort.select.3}</option>
						            <option value="4" {if $_var['gp_sltSort'] == 4}selected="selected"{/if}>{lang user.index.view.search.sort.select.4}</option>
					            </select>
					            </label>
							</td>
						</tr>
						<tr>
							<td>{lang admin.search.time}</td>
							<td>
								<input type="text" name="txtBeginDate" maxlength="16" class="input-medium input-date" value="{$_var[gp_txtBeginDate]}" />
					            {lang admin.search.to}
					            <input type="text" name="txtEndDate" maxlength="16" class="input-medium input-date" value="{$_var[gp_txtEndDate]}" />
							</td>
						</tr>
						<tr>
							<td>{lang user.index.view.search.credit}</td>
							<td>
								<input type="text" name="txtMinCredit" maxlength="10" class="input-small" value="{$_var[gp_txtMinCredit]}" />
					            {lang user.index.view.search.credit.0}
					            <input type="text" name="txtMaxCredit" maxlength="10" class="input-small" value="{$_var[gp_txtMaxCredit]}" />
					            
					            &nbsp;
					            {lang user.index.view.search.score}　
					            <input type="text" name="txtMinScore" maxlength="10" class="input-small" value="{$_var[gp_txtMinScore]}" />
					            {lang user.index.view.search.score.0}
					            <input type="text" name="txtMaxScore" maxlength="10" class="input-small" value="{$_var[gp_txtMaxScore]}" />
							</td>
						</tr>
						<tr>
							<td></td>
							<td>
								<button type="submit" class="btn btn-primary">{lang admin.search.submit.extend.submit}</button>
							</td>
						</tr>
						</table>
						</form>
					</div>
					
					<hr/>
					<form id="frm_grid" name="frmGrid" action="{$ADMIN_SCRIPT}/user&page={$_var[page]}&psize={$_var[psize]}" method="post">
					<table class="table table-hover">
						<thead>
							 <tr>
								<th width="30"><input type="checkbox" class="fancy" name="cbxAll"/></th>
								<th width="80">{lang user.index.view.th.cname}</th>
								<th>{lang user.index.view.th.username}/{lang user.index.view.th.realname}</th>
						        <th	width="150">{lang user.index.view.th.email}/{lang user.index.view.th.other}</th>
								<th	width="150">{lang user.index.view.th.mobile}/{lang user.index.view.th.phone}</th>
						        <th width="80">{lang user.index.view.th.credit}/{lang user.index.view.th.score}</th>
						        <th width="130">{lang user.index.view.th.createtime}/{lang user.index.view.th.logintime}</th>
						        <th width="90">{lang user.index.view.th.operation}</th>
							</tr>
						</thead>
						<tbody>
							<!--{loop $users $_loop $user}-->
								<tr class="item-row">
		        					<td>
						                <input type="checkbox" class="fancy" name="cbxItem[]" username="{$user[USERNAME]}" value="{$user[USERID]}" />
		           					</td>
		           					<td>{$user[CNAME]} {$user[WRONG]}</td>
									<td>
										<p class="{echo $user['ISAUDIT'] ? 'text-warning' : '';}">
											{$user[USERNAME]}<br/>
											{echo cutstr($user[REALNAME], 80);} <span class="f10">ID:{$user[USERID]}</span>
										</p>
									</td>
						            <td>
							            {$user[EMAIL]}
							            <p class="muted">{$user[COMMENT]}</p>
						            </td>
									<td>
										{$user[MOBILE]}<br/>
										{$user[PHONE]}
									</td>
						            <td>
						            	{$user[CREDIT]}<br/>
						            	{$user[SCORE]}{lang user.index.view.td.score}
						            </td>
						            <td class="f10">
							            {echo $user['CREATETIME'] + 0 > 0 ? date('Y-m-d H:i', strtotime($user['CREATETIME'])): '';}<br/>
							            {echo $user['LOGINTIME'] + 0 > 0 ? date('Y-m-d H:i', strtotime($user['LOGINTIME'])): '';}
						            </td>
						            <td>
						                <a class="btn btn-mini btn-primary" href="{$ADMIN_SCRIPT}/user/_update&id={$user[USERID]}&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}" {$dispatches[operations][edit]}>{lang admin.operation.edit}</a>
					                	<a class="btn btn-mini btn-delete" username="{$user[USERNAME]}" data="{$user[USERID]}" href="javascript:void(null);" {$dispatches[operations][delete]}>{lang admin.operation.delete}</a>		            
						            </td>
								</tr>
					            <!--{/loop}-->
					            <!--{if count($users) == 0}-->
						        <tr>
						            <td colspan="8">
						                * {lang admin.operation.empty}
						            </td>
						        </tr>
						        <!--{/if}-->
						</tbody>
					</table>
					</form>
					
					<hr/>
					{$pager}
				</div>
			</div>
		</div>
	</div>
</div>

<script>
function search_toggle(){
	var state = $('#btn_extend_search').attr('state');
	if(state == '0'){
		$('#btn_extend_search').html('{lang admin.search.submit.extend.hide}<i class="micon-arrow-up"></i>').attr('state', '1');
	}else{
		$('#btn_extend_search').html('{lang admin.search.submit.extend}<i class="micon-arrow-down"></i>').attr('state', '0');
	}
	
	$('.pull-right .input-append').toggle();
	$('#div_extend_search').toggle();
}

$(function(){
	$('.fancy').uniform();
	$('.input-date').datepicker({format:'yyyy-mm-dd'});
	
	$('#btn_enable_list').click(function(){
		if($("#frm_grid input[name='cbxItem[]']:checked").length > 0){
			var tempHTML = '<p>';
			$("#frm_grid input[name='cbxItem[]']:checked").each(function(){
				tempHTML += $(this).attr('username') + '； ';
			});
			
			tempHTML += '</p>';
			
			$.dialog({submit:'{lang admin.operation.enable}', message:'<p>{lang user.index.view.operation.enable.message}</p>' + tempHTML, callback:function(){
				$('#modal_dialog .btn-primary').click(function(){
					$('#frm_grid').attr('action', "{$ADMIN_SCRIPT}/user&do=enable_list&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}");
					$('#frm_grid').submit();
				});
			}});
		}else $.dialog({message:'{lang user.index.view.operation.empty}'});
	});
	
	$('#btn_disable_list').click(function(){
		if($("#frm_grid input[name='cbxItem[]']:checked").length > 0){
			var tempHTML = '<p>';
			$("#frm_grid input[name='cbxItem[]']:checked").each(function(){
				tempHTML += $(this).attr('username') + '； ';
			});
			
			tempHTML += '</p>';
			
			$.dialog({submit:'{lang admin.operation.disable}', message:'<p>{lang user.index.view.operation.disable.message}</p>' + tempHTML, callback:function(){
				$('#modal_dialog .btn-primary').click(function(){
					$('#frm_grid').attr('action', "{$ADMIN_SCRIPT}/user&do=disable_list&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}");
					$('#frm_grid').submit();
				});
			}});
		}else $.dialog({message:'{lang user.index.view.operation.empty}'});
	});
	
	$('#btn_modify_list').click(function(){
		if($("#frm_grid input[name='cbxItem[]']:checked").length > 0){
			$.dialog({submit:'{lang admin.operation.submit}', title:'{lang user.index.view.operation.modify.message}', href:'{$ADMIN_SCRIPT}/user/_modify&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}', callback:function(){
				$('#modal_dialog .btn-primary').click(function(){
					if($('#slt_BGroupID').val() == '0'){
						$('#slt_BGroupID').focus();
						return;
					}
					
					var userids = '';
				 	var checkboxs = $("#frm_grid input[name='cbxItem[]']:checked");
				 	for(var i = 0; i < checkboxs.length; i++){
				 		userids += checkboxs[i].value + ',';
				 	}
				 	
				 	$('#hdn_UserIds').val(userids);
				 	$('#frm_dialog').submit();
				 	$('#modal_dialog').modal('hide').remove();
				});
				
				$("#modal_dialog .fancy").uniform();
			}});
		}else $.dialog({message:'{lang user.index.view.operation.empty}'});
	});
	
	$('#btn_delete_list').click(function(){
		if($("#frm_grid input[name='cbxItem[]']:checked").length > 0){
			var tempHTML = '<p>';
			$("#frm_grid input[name='cbxItem[]']:checked").each(function(){
				tempHTML += $(this).attr('username') + '； ';
			});
			
			tempHTML += '</p>';
			
			$.dialog({submit:'{lang admin.operation.delete}', message:'<p>{lang user.index.view.operation.delete.message}</p>' + tempHTML, callback:function(){
				$('#modal_dialog .btn-primary').click(function(){
					$('#frm_grid').attr('action', "{$ADMIN_SCRIPT}/user&do=delete_list&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}");
					$('#frm_grid').submit();
				});
			}});
		}else $.dialog({message:'{lang user.index.view.operation.empty}'});
	});
	
	$('#btn_export').click(function(){
		window.open('{$ADMIN_SCRIPT}/user/_excel{$search[querystring]}');
	});
	
	$('#btn_extend_search').click(function(){
		search_toggle();
	});
	
	$("#frm_grid input[name='cbxAll']").click(function(){
		if(this.checked){
			$('#frm_grid .item-row').addClass('warning');
			$("#frm_grid input[name='cbxItem[]']").attr('checked', true).parent().addClass('checked');
		}else{
			$('#frm_grid .item-row').removeClass('warning');
			$("#frm_grid input[name='cbxItem[]']").attr('checked', false).parent().removeAttr('class');
		}
	});
	
	$("#frm_grid input[name='cbxItem[]']").click(function(){
		if(this.checked) $(this).parent().parent().parent().parent().addClass('warning');
		else $(this).parent().parent().parent().parent().removeClass('warning');
	});
	
	$('#frm_grid .btn-delete').click(function(){
		var userid = $(this).attr('data');
		var tempHTML = '<p>' + $(this).attr('username') + '； </p>';
		$.dialog({submit:'{lang admin.operation.delete}', message:'<p>{lang user.index.view.operation.delete.message}</p>' + tempHTML, callback:function(){
			$('#modal_dialog .btn-primary').click(function(){
				$('#frm_grid').attr('action', "{$ADMIN_SCRIPT}/user&do=delete&id="+ userid +"&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}");
				$('#frm_grid').submit();
			});
		}});
	});
	
	{if $_var[gp_hdnSearchShow]}
	search_toggle();
	{/if}
});
</script>
<!--{template /module/admin/view/foot}-->